let vm = new Vue({
    el: '#app',  //选中整个main
    data: {
        meeting: {
            deptId: '1',
            deptName: '',
            title: '',
            content: '',
            publishDate: '',
            startTime: '',
            endTime: '',
            status: '',
            makeUser: ''
        },//初始化对象     vue建议声明对象同时进行初始化，避免undefinded
        depts: {},
        users: {
            id: '',
            realName: ''
        },
        userIds: []
    },
    methods: {
        //获取所有部门信息
        getAlldept: function () {
            axios.get("dept/selectAll").then(rs => {
                this.depts = rs.data.obj;
            }).catch(error => {
                layer.msg(error.mssage);
            })
        },
        getUsers: function () {
            axios.get(`meeting/getUsers/${this.meeting.deptId}`).then(rs => {
                this.users = rs.data.obj;
            }).catch(error => {
                layer.msg(error.mssage);
            }).finally(rs=>{
                $("#userSP").selectpicker('refresh');
            })
        },
        //添加会议
        addMeeting: function () {
            // this.meeting.startTime=new Date(this.meeting.startTime);
            // this.meeting.endTime=new Date(this.meeting.endTime);
            axios.post(`meeting/addMeeting/${this.userIds}+''`, this.meeting).then(rs => {
                // this.users=rs.data.obj;
                layer.msg(rs.data.obj);
                location.href = 'html/meeting.html'
            }).catch(error => {
                layer.msg(error.mssage);
            })
        },
        dateDefind() {
            var d, s;
            var self = this;
            d = new Date();
            s = d.getFullYear() + "-";             //取年份
            s = s + (d.getMonth() + 1) + "-";//取月份
            s += d.getDate() + " ";         //取日期
            s += d.getHours() + ":";       //取小时
            s += d.getMinutes() + ":";    //取分
            s += d.getSeconds();         //取秒
            self.time = s;
            //初始化
            $('#startTime').datetimepicker({
                startDate: s,
                minView: "hour", //选择日期后，不会再跳转去选择时分秒
                language: 'zh-CN',
                format: 'yyyy-mm-dd hh:ii:ss',
                todayBtn: 1,
                autoclose: 1
            });
            //当选择器隐藏时，讲选择框只赋值给data里面的time
            $('#startTime').datetimepicker()
                .on('hide', function (ev) {
                    var value = $("#startTime").val();
                    self.meeting.startTime = value;
                });
            //初始化
            $('#endTime').datetimepicker({
                startDate: s,
                minView: "hour", //选择日期后，不会再跳转去选择时分秒
                language: 'zh-CN',
                format: 'yyyy-mm-dd hh:ii:ss',
                todayBtn: 1,
                autoclose: 1
            });
            //当选择器隐藏时，讲选择框只赋值给data里面的time
            $('#endTime').datetimepicker()
                .on('hide', function (ev) {
                    var value = $("#endTime").val();
                    self.meeting.endTime = value;
                });
        }
    },
    created: function () {
        this.getAlldept();
        this.getUsers();
    },
    mounted: function () {
        this.dateDefind();
    }

});